home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / WAREZ 1.1 source Folder / warez ƒ / MSG Shell ƒ / msg integrity.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-07  |  2.2 KB  |  83 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        msg integrity.c
  4.  
  5. Purpose:    This module implements a quick-and-dirty integrity check;
  6.             compare the resource fork and map length to stored values.
  7.             (Drop the completed application on "Prepare" to store
  8.             these values in the right place.)
  9.  
  10.  
  11. WAREZ -=- nostalgia isn't what it used to be
  12. Copyright ©1994, Mark Pilgrim
  13.  
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation; either version 2 of the License, or
  17. (at your option) any later version.
  18.  
  19. This program is distributed in the hope that it will be useful,
  20. but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22. GNU General Public License for more details.
  23.  
  24. You should have received a copy of the GNU General Public License
  25. along with this program in a file named "GNU General Public License".
  26. If not, write to the Free Software Foundation, 675 Mass Ave,
  27. Cambridge, MA 02139, USA.
  28.  
  29. \**********************************************************************/
  30.  
  31. #include "msg integrity.h"
  32. #include "msg graphics.h"
  33. #include "msg dialogs.h"
  34. #include "program globals.h"
  35.  
  36. void DoIntegrityCheck(void)
  37. {
  38.     int                thisFile;
  39.     long            count;
  40.     long            resDataLength, checkData;
  41.     long            resMapLength, checkMap;
  42.     Boolean            problem;
  43.     
  44.     problem=FALSE;
  45.     FlushVol(0L, 0);
  46.     OpenRF(CurApName, 0, &thisFile);
  47.     if (!problem)
  48.     {
  49.         SetFPos(thisFile, 1, 8L);
  50.         count=4L;
  51.         problem=(FSRead(thisFile, &count, (Ptr)(&resDataLength))!=noErr);
  52.     }
  53.     if (!problem)
  54.     {
  55.         SetFPos(thisFile, 1, 12L);
  56.         count=4L;
  57.         problem=(FSRead(thisFile, &count, (Ptr)(&resMapLength))!=noErr);
  58.     }
  59.     if (!problem)
  60.     {
  61.         SetFPos(thisFile, 1, 144L);
  62.         count=4L;
  63.         problem=(FSRead(thisFile, &count, (Ptr)(&checkData))!=noErr);
  64.     }
  65.     if (!problem)
  66.     {
  67.         SetFPos(thisFile, 1, 148L);
  68.         count=4L;
  69.         problem=(FSRead(thisFile, &count, (Ptr)(&checkMap))!=noErr);
  70.     }
  71.     
  72.     if (!problem)
  73.         problem=((resDataLength!=checkData) || (resMapLength!=checkMap));
  74.  
  75.     if (problem)
  76.     {
  77.         ParamText(APPLICATION_NAME, "\p", "\p", "\p");
  78.         PositionDialog('ALRT', integrityCheckFailAlert);
  79.         StopAlert(integrityCheckFailAlert,0L);
  80.         ExitToShell();
  81.     }
  82. }
  83.